<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" indent="yes"/>
<xsl:strip-space elements="*"/>

<xsl:template match="/beans">
digraph SpringBeans {
rankdir="LR";
<xsl:apply-templates/>
}
</xsl:template>

<xsl:template match="bean">
"<xsl:value-of select="@id"/>" [
  shape=Mrecord,
  label="<xsl:value-of select="@id" />\n<xsl:value-of select="@class" />|<xsl:apply-templates mode="propList" />"
  ];
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="property/ref">
"<xsl:value-of select="../../@id" />":"<xsl:value-of select="@bean|@local" />" -> "<xsl:value-of select="@bean|@local" />" ;
</xsl:template>

<xsl:template match="property/list/ref">
"<xsl:value-of select="generate-id(..)" />":"<xsl:value-of select="@bean|@local" />" -> "<xsl:value-of select="@bean|@local" />" ;
</xsl:template>

<xsl:template match="property/list/entry/ref">
"<xsl:value-of select="generate-id(../..)" />":"<xsl:value-of select="@bean|@local" />" -> "<xsl:value-of select="@bean|@local" />";
</xsl:template>

<xsl:template match="value" mode="propList"><xsl:if test="not(ancestor::list|ancestor::map) or position() > 1">|</xsl:if><xsl:if test="../@name"><xsl:value-of select="../@name" /> = </xsl:if>\"<xsl:value-of select="." />\"</xsl:template>

<xsl:template match="ref[@local]" mode="propList"><xsl:if test="not(ancestor::list|ancestor::map) or position() > 1">|</xsl:if>&lt;<xsl:value-of select="@local" />&gt;<xsl:value-of select="@local" /></xsl:template>

<xsl:template match="ref[@bean]" mode="propList"><xsl:if test="not(ancestor::list|ancestor::map) or position() > 1">|</xsl:if>&lt;<xsl:value-of select="@bean" />&gt;<xsl:value-of select="@bean" /></xsl:template>

<xsl:template match="property/list|property/map" mode="propList">|&lt;<xsl:value-of select="generate-id(.)" />&gt;<xsl:value-of select="../@name" /></xsl:template>

<xsl:template match="property/list | property/map">
<xsl:value-of select="generate-id(.)"/> [
  shape=record, 
  style=filled, 
  fillcolor=grey,
  label="<xsl:apply-templates mode="propList" />"
  ];
"<xsl:value-of select="../../@id"/>":"<xsl:value-of select="generate-id(.)"/>" -> "<xsl:value-of select="generate-id(.)"/>" ;
<xsl:apply-templates />
</xsl:template>

<xsl:template match="text()" />

</xsl:stylesheet>